#include "connectionplayer.h"

ConnectionPlayer::ConnectionPlayer(QHostAddress a, quint16 p, bool onlyReceive) : Connection(a,p,onlyReceive)
{
	dirs.clear();
	dirs.append(0);
	dirs.append(0);
	isAlive = false;
}

ConnectionPlayer::ConnectionPlayer(bool onlyReceive) : Connection(onlyReceive)
{
	dirs.clear();
	dirs.append(0);
	dirs.append(0);
	isAlive = false;
}

void ConnectionPlayer::setNick(QString n)
{
    nick = n;
}

void ConnectionPlayer::setScore(quint16 s)
{
    score = s;

}

void ConnectionPlayer::setPlayerId(quint8 id)
{
    player_id = id;
}

void ConnectionPlayer::setPosition(QPointF p)
{

	if (pos != p)
	{
		pos = p;
		emit positionChanged(p);
	}
}

void ConnectionPlayer::setIsAlive(bool ia)
{
	if (isAlive != ia)
	{
		//qDebug() << "making connplayer alive" << ia;
		isAlive = ia;
		emit isAliveChanged(ia);
	}
}


void ConnectionPlayer::setIsReloading(bool isr)
{
	if (isReloading != isr)
	{
		isReloading = isr;
		emit isReloadingChanged(isr);
	}
}

void ConnectionPlayer::setAngle(qint16 a)
{
	if (angle != a)
	{
		angle = a;
		emit angleChanged(a);
	}
}

void ConnectionPlayer::setDirs(quint8 d1, quint8 d2)
{
	dirs.clear();
	dirs.append(d1);
	dirs.append(d2);
	emit dirsChanged(d1,d2);
}

void ConnectionPlayer::fireGun(qreal x, qreal y, qreal ang)
{
	qDebug() << "emit gun fired";
	emit gunFired(x,y,ang);
}

QString ConnectionPlayer::getNick()
{
    return nick;
}

quint16 ConnectionPlayer::getScore()
{
    return score;
}

quint8 ConnectionPlayer::getPlayerId()
{
    return player_id;
}

QPointF ConnectionPlayer::getPos()
{
	return pos;
}

bool ConnectionPlayer::getIsAlive()
{
	return isAlive;
}

bool ConnectionPlayer::getIsReloading()
{
	return isReloading;
}

qint16 ConnectionPlayer::getAngle()
{
	return angle;
}
